package cn.zongtilei;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class CookieServlet2
 */
public class CookieServlet2 extends HttpServlet {
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		Cookie[] cookies = req.getCookies();
		for (Cookie cookie : cookies) { // 获取所有cookie，用c.getName()分别获取每个cookie名
			if (cookie.getName().equals("goods")) {
				String value = cookie.getValue();
				System.out.println("goods： " + value);
			}
		}
	}

}
